<!DOCTYPE html> 
<html> 
	<head>
	<meta charset="utf-8">
	<meta name="viewport" content="width=device-width, initial-scale=1"> 
	<title>jQuery Mobile Docs - Flip switch</title> 
	<link rel="stylesheet"  href="../../themes/default/" />  
	<link rel="stylesheet" href="../_assets/css/jqm-docs.css"/>
	<script src="../../js/jquery.js"></script>
	<script src="../../experiments/themeswitcher/jquery.mobile.themeswitcher.js"></script>
	<script src="../_assets/js/jqm-docs.js"></script>
	<script src="../../js/"></script>
</head> 
<body> 

	<div data-role="page" class="type-interior">

		<div data-role="header" data-theme="f">
		<h1>Flip switch</h1>
	</div><!-- /header -->

	<div data-role="content">
		<div class="content-primary">
		
		<form action="#" method="get">

				<h2>Flip toggle switches</h2>
				<p>A binary "flip" switch is a common UI element on mobile devices that is used for any binary on/off or true/false type of data input. You can either drag the flip handle like a slider or tap on each half of the switch.</p>
				<p>To create a flip toggle,  To add a slider widget to your page, start with an <code>select</code> with two options. The first option will be styled as the "on" state switch and the second will be styled as the "off" state so write your options in the correct order. Set the <code>for</code> attribute of the <code>label</code> to match the ID of the <code>input</code> so they are semantically associated and wrap them in a <code>div</code> with the <code> data-role="fieldcontain"</code> attribute to group them.</p>

<pre><code>	
&lt;div data-role=&quot;fieldcontain&quot;&gt;
	&lt;label for=&quot;slider&quot;&gt;Select slider:&lt;/label&gt;
	&lt;select name=&quot;slider&quot; id=&quot;slider&quot; data-role=&quot;slider&quot;&gt;
		&lt;option value=&quot;off&quot;&gt;Off&lt;/option&gt;
		&lt;option value=&quot;on&quot;&gt;On&lt;/option&gt;
	&lt;/select&gt; 
&lt;/div&gt;
</code></pre>	
		<p>The flip toggle switch is displayed like this:</p>
		<div data-role="fieldcontain">
			<label for="slider">Flip switch:</label>
			<select name="slider" id="slider" data-role="slider">
				<option value="off">Off</option>
				<option value="on">On</option>
			</select> 
		</div>



<h2>Refreshing a flip switch</h2>
        
<p>If you manipulate a flip switch via JavaScript, you must call the refresh method on it to update the visual styling. Here is an example:</p>

<code><pre>
var myswitch = $("select#bar");
myswitch[0].selectedIndex = 1;
myswitch .slider("refresh");
</pre></code>

	</form>
	
	</div><!--/content-primary -->		
	
	<div class="content-secondary">
		
		<div data-role="collapsible" data-collapsed="true" data-theme="b">
			
				<h3>More in this section</h3>
				
				<ul data-role="listview" data-theme="c" data-dividertheme="d">
				
					<li data-role="list-divider">Form elements</li>
					<li><a href="docs-forms.html">Form basics</a></li>
					<li><a href="forms-all.html">Form element gallery</a></li>
					<li><a href="forms-text.html">Text inputs</a></li>
					<li><a href="forms-search.html">Search inputs</a></li>
					<li><a href="forms-slider.html">Slider</a></li>
					<li data-theme="a"><a href="forms-switch.html">Flip toggle switch</a></li>
					<li><a href="forms-radiobuttons.html">Radio buttons</a></li>
					<li><a href="forms-checkboxes.html">Checkboxes</a></li>
					<li><a href="forms-selects.html">Select menus</a></li>
					<li><a href="forms-themes.html">Theming forms</a></li>
					<li><a href="forms-all-native.html">Native form elements</a></li>
					<li><a href="forms-sample.html">Submitting forms</a></li>
					<li><a href="plugin-eventsmethods.html">Plugin methods</a></li>
	
				</ul>
		</div>
	</div>		

</div><!-- /content -->

<div data-role="footer" class="footer-docs" data-theme="c">
		<p>&copy; 2011 Mobile MonArch 7.51</p>
</div>
	
</div><!-- /page -->

</body>
</html>

